package cn.sylinx.horm.dialect.fs.builder;

import cn.sylinx.horm.dialect.fs.FS;

class DerbyFS<T> extends FS<T> {

    public static <T> FS<T> of(Class<T> modelClass) {
        return new DerbyFS<T>().init(modelClass);
    }

    public static <T> FS<T> of(Class<T> modelClass, String tablePostfix) {
        return new DerbyFS<T>().init(modelClass, tablePostfix);
    }

    public static <T> FS<T> of(String tablePrefix, Class<T> modelClass) {
        return new DerbyFS<T>().init(tablePrefix, modelClass);
    }

    public static <T> FS<T> of(String tablePrefix, Class<T> modelClass, String tablePostfix) {
        return new DerbyFS<T>().init(tablePrefix, modelClass, tablePostfix);
    }

    @Override
    public FS<T> limit(int offset, int size) {
        if (limitSQL.length() == 0) {
            // OFFSET ? ROWS FETCH NEXT ? ROWS ONLY
            limitSQL.append(" OFFSET ").append(offset).append(" ROWS FETCH NEXT ").append(size).append(" ROWS ONLY");
        }
        return this;
    }

}
